package com.david.IfaceAutoTest.mapper;

import com.david.IfaceAutoTest.domain.TableDomain;
import com.david.IfaceAutoTest.entity.Interface;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author david
 * @since 2021-12-14
 */
public interface InterfaceMapper extends BaseMapper<Interface> {
    @Select("select c.relname tableName,cast(obj_description(relfilenode,'pg_class') as varchar) tableDesc,a.attname fieldName,d.description fieldDesc,concat_ws('',t.typname,SUBSTRING(format_type(a.atttypid,a.atttypmod) from '\\(.*\\)')) as fieldType from pg_class c,pg_attribute a,pg_type t,pg_description d where a.attnum>0 and a.attrelid=c.oid and a.atttypid=t.oid and d.objoid=a.attrelid and d.objsubid=a.attnum\n" +
            "and c.relname =#{tableName}  order by c.relname,a.attnum")
    List<TableDomain> getTableDomain(@Param("tableName") String tableName);


    List<Map<String,Object>> getTest();
}
